<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>社区公告修改</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script type="text/javascript" src="../lib/layui-v2.6.4/layui/layui.js"></script>
    <script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-form" style="margin-left: 30%;margin-top: 5%">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>ID</label>
                <div class="layui-input-inline">
                    <input type="text" name="ntitle" id="nid"
                           class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>标题</label>
                <div class="layui-input-inline">
                    <input type="text" name="ntitle" id="ntitle"
                           class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>内容</label>
                <div class="layui-input-inline">
                    <input type="text" name="username"  id="ncontent"
                           class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" id="butt" lay-submit="">增加</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script>
    layui.use(['table','jquery','layer'], function(){
        var table = layui.table;
        var $=layui.jquery;
        layer = layui.layer;
        $.ajax({
            type:'GET',
            url:"http://localhost:8080/api/xgcxgg",
            data:{"id":sessionStorage.getItem("nid")},
            headers:{
                token:localStorage.getItem("token")
            },
            datatype: "json",
            success:function (data){
                let nid=sessionStorage.getItem("nid")
                let ntitle=sessionStorage.getItem("ntitle")
                let ncontent=sessionStorage.getItem("ncontent")
                $("#nid").val(nid);
                $("#ntitle").val(ntitle);
                $("#ncontent").val(ncontent);
            }
        })
    })

    $("#butt").click(function (){
        layui.use(['table','jquery','layer'], function(){
            var table = layui.table;
            var $=layui.jquery;
            var layer=layui.layer;

            let nid=$("#nid").val();
            let ntitle=$("#ntitle").val();
            let ncontent=$("#ncontent").val();
            $.ajax({
                type:"POST",
                url:"http://localhost:8080/api/xggg",
                data:{"nId":nid,"nTitle":ntitle,"nContent":ncontent},
                headers:{
                    token:localStorage.getItem("token")
                },
                datatype: "json",
                success:function (data){
                    if (data!=""){
                        var index = parent.layer.getFrameIndex(window.name);
                        layer.msg('社区信息修改成功!',{
                            icon:1
                            ,time:800
                        },function (){
                            parent.layer.close(index);//关闭当前页
                        });
                    }
                }
            })
        })
    })
</script>
